import 'package:flutter/material.dart';
import 'package:full_display/common/qxp_color.dart';
import 'package:full_display/common/qxp_style.dart';
import 'package:full_display/unit/asset_utils/asset_utils.dart';
import 'package:full_display/unit/screen/screen_utility.dart';
import 'package:full_display/unit/web_socket/web_sockect_utils.dart';

class ButtonAddSubWidget extends StatelessWidget {
  final String title;
  ButtonAddSubWidget({Key? key, required this.title}) : super(key: key);

  bool isClick = false;
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(left: 20.0.W, top: 20.0.H),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            title,
            textAlign: TextAlign.center,
            style: StandardTextStyle.textWhite12Style,
          ),
          Container(
            padding: EdgeInsets.only(top: 15.0.H),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                Container(
                  child: InkWell(
                    onTap: () {
                      tapClick();
                      WebSocketUtils().sendMessage(16, content: 0);
                    },
                    child: Image.asset(
                      AssetUtils.getAsset2Image("icon_sub"),
                      width: 24.0.W,
                      height: 24.0.H,
                    ),
                  ),
                ),
                Container(width: 15.0.H),
                Container(
                  padding: EdgeInsets.only(top: 5.0.H),
                  width: 97.0.H,
                  height: 24.0.H,
                  decoration: BoxDecoration(
                    border: Border.all(color: ColorPlate.white, width: 0.5),
                    borderRadius: BorderRadius.all(Radius.circular(12.0.H)),
                  ),
                  child: Text(
                    '1',
                    textAlign: TextAlign.center,
                    style: StandardTextStyle.textWhite12Style,
                  ),
                ),
                Container(width: 15.0.H),
                Container(
                  child: InkWell(
                    onTap: () {
                      tapClick();
                      WebSocketUtils().sendMessage(16, content: 1);
                    },
                    child: Image.asset(
                      AssetUtils.getAsset2Image("icon_device_add"),
                      width: 24.0.W,
                      height: 24.0.H,
                    ),
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }

  tapClick() {
    if (!isClick) {
      isClick = true;
      WebSocketUtils().sendMessage(17);
    }
  }
}
